import java.util.Scanner;

public class Demo{
    private static Object locker=new Object();
    public static void main(String[] args) {
        Thread t1=new Thread(()->{
              synchronized (locker){
                  System.out.println("t1wait之前");
                  try {
                      locker.wait();
                      System.out.println("t1wait之后");
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
        });
        Thread t2=new Thread(()->{
            synchronized (locker){
                System.out.println("t2wait之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("t2wait之后");
            }
        });
        Thread t3=new Thread(()->{
            synchronized (locker){
                System.out.println("t3wait之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("t3wait之后");
            }
        });
        Thread t4=new Thread(()->{
           synchronized (locker){
               Scanner scanner=new Scanner(System.in);
               scanner.next();
               System.out.println("t4notify之前");
               locker.notifyAll();
               System.out.println("t4notify之后");
           }
        });
        t1.start();
        t2.start();
        t3.start();
        t4.start();
    }
}
